package com.zeroxml.cms.dao.impl;

import com.wyvoid.core.persistent.hibernate.HibernateDAO;
import com.zeroxml.cms.bo.Catalog;
import com.zeroxml.cms.dao.ICatalogDAO;

import java.util.List;

/**
 * User: cjp
 * Date: 2007-9-9
 * Time: 19:39:11
 */
public class CatalogDAO extends HibernateDAO<Catalog> implements ICatalogDAO {
    public List<Catalog> getCatalogList(long parentId) {
        String hql = "from Catalog where status>= "+Catalog.STATUS_NORMAL;
        if(parentId>0){
            hql+=" and parentCatalog.id="+parentId;
        }else{
            hql+=" and parentCatalog is null ";
        }
        hql+=" order by orders desc";
        return doQueryList(hql,true);
    }

    public Catalog getCatalog(String name) {
        String hql="from Catalog where name=?";
        return doQueryUnique(hql,name);
    }
}
